#ifndef _SOCKET_INPUT_H_
#define _SOCKET_INPUT_H_
#pragma once

#include <pcap.h>
#include <stdio.h>
#include <unistd.h>

#include "modules/drivers/lidar/orin_hesai/hesai_utils/hesai_data_type.h"

namespace apollo {
namespace drivers {
namespace lidar_hesai {
static const size_t ETHERNET_HEADER_SIZE = 42;
static const int PCAP_FILE_END = -1;
static const int SOCKET_TIMEOUT = -2;
static const int RECIEVE_FAIL = -3;
static const int POLL_TIMEOUT = 1000;  // one second (in msec)

class SocketInput {
 public:
  SocketInput() : sockfd_(-1) {};
  ~SocketInput(){};
  bool Init(uint32_t port, size_t firing_data_packet_size);
  int GetFiringDataPacket(HesaiLidarPacketData* pkt);

 private:
  bool InputAvailable(int timeout);

 private:
  int32_t sockfd_;
  int port_;
  size_t firing_data_packet_size_;
};
}  // namespace lidar_hesai
}  // namespace drivers
}  // namespace apollo
#endif
